-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ImmutableEnumSetRules
Refaster rule collection
#1302
Conversation
Quality Gate passedIssues Measures |
Looks good. No mutations were possible for these changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly some tweaks to Refaster rule names. Nice new collection @mohamedsamehsalah 🚀!
Added a commit.
Suggested commit message:
Introduce `ImmutableEnumSetRules` Refaster rule collection (#1302)
* Prefer {@link Sets#immutableEnumSet(Iterable)} for enum collections to take advantage of | ||
* internally used {@link EnumSet}. | ||
*/ | ||
static final class ImmutableEnumSetIterable<T extends Enum<T>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The yet-to-be formalized Refaster naming algorithm would add the Sets
here in front :).
*/ | ||
static final class ImmutableEnumSetIterable<T extends Enum<T>> { | ||
@BeforeTemplate | ||
ImmutableSet<T> before(Collection<T> elements) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the name wanted to change this to an Iterable, but that doesn't work here, the copyOf
expects a Collection
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, there's an Iterable
-accepting overload. Just means we need to cover both cases.
} | ||
|
||
ImmutableSet<ImmutableSet<RoundingMode>> testImmutableEnumSetIterable() { | ||
return ImmutableSet.of( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can simplify the first two tests to simply have one test case :).
RoundingMode.UNNECESSARY))); | ||
} | ||
|
||
ImmutableSet<RoundingMode> testImmutableEnumSetSixElements() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For other similar rules we stopped at 5, but because its already here, might as well leave it in 😉.
8d0eeb7
to
e80ef1d
Compare
Looks good. No mutations were possible for these changes. |
1 similar comment
Looks good. No mutations were possible for these changes. |
e80ef1d
to
81bf53e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased and added a commit.
*/ | ||
static final class ImmutableEnumSetIterable<T extends Enum<T>> { | ||
@BeforeTemplate | ||
ImmutableSet<T> before(Collection<T> elements) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, there's an Iterable
-accepting overload. Just means we need to cover both cases.
} | ||
|
||
ImmutableSet<RoundingMode> testSetsImmutableEnumSetIterable() { | ||
return Sets.immutableEnumSet(EnumSet.range(RoundingMode.UP, RoundingMode.UNNECESSARY)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the shorter EnumSet.allOf(RoundingMode.class)
here.
* Prefer {@link Sets#immutableEnumSet(Iterable)} for enum collections to take advantage of the | ||
* internally used {@link EnumSet}. | ||
*/ | ||
static final class SetsImmutableEnumSetIterableArray<T extends Enum<T>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this one we'll likely name SetsImmutableEnumSetArraysAsList
eventually; let's do already.
* Prefer {@link Sets#immutableEnumSet(Enum, Enum[])} for enum collections to take advantage of | ||
* the internally used {@link EnumSet}. | ||
*/ | ||
static final class SetsImmutableEnumSet6<T extends Enum<T>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>6 variants aren't rewritten; will add comment.
* Prefer {@link Sets#immutableEnumSet(Enum, Enum[])} for enum collections to take advantage of | ||
* the internally used {@link EnumSet}. | ||
*/ | ||
static final class ImmutableEnumSetVarArgs<T extends Enum<T>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static final class ImmutableEnumSetVarArgs<T extends Enum<T>> { | |
static final class SetsImmutableEnumSetVarArgs<T extends Enum<T>> { |
* com.google.common.collect.ImmutableEnumSet}s. | ||
*/ | ||
@OnlineDocumentation | ||
final class ImmutableEnumSetRules { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we have a new rule collection, we should move the StreamToImmutableEnumSet
rule from AssortedRules
.
That rule also contains a warning that applies to the new rules.
Looks good. No mutations were possible for these changes. |
ImmutableEnumSetRules
refaster rulesImmutableEnumSetRules
Refaster rule collection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't have time to check the changes too thoroughly but they look good!
81bf53e
to
fd415f5
Compare
Quality Gate passedIssues Measures |
Looks good. No mutations were possible for these changes. |
Thanks @Stephan202 🙏 |
Suggested commit message